package softdone;

import java.sql.*;
import java.util.ArrayList;
import java.util.Collection;

import softdata.Rep_data;

public class Rep_done {
	public Collection Replies;
	public int Num_Page;		//每页显示的回复数 
	public void Rep_Reply(int id_post,int id_user,int id_reply,String content){
		/*
		 * 函数功能： 添加回帖，并返回帖子楼数
		 */
		String sql="{call reply_reply(?,?,?,?)}";
		try{
			Conn dataconn=new Conn();
			dataconn.Create();
			CallableStatement cs=dataconn.CSt_SQL(sql);
			cs.setInt(1,id_post);
			cs.setInt(2,id_user);
			cs.setInt(3,id_reply);
			cs.setString(4,content);
			cs.execute();
		    dataconn.CloseCC();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public void Rep_Read(int id,int page){
		String sql="{call reply_read(?,?)}";
		try{
			Replies=new ArrayList();
			Num_Page=0;
			Conn dataconn=new Conn();
			dataconn.Create();
			CallableStatement cs=dataconn.CSt_SQL(sql);
			cs.setInt(1,id);
			cs.setInt(2,page);
			ResultSet rs=cs.executeQuery();
			while(rs.next()){
				Rep_data repdata=new Rep_data();
				repdata.ID_User=rs.getInt(1);
				repdata.Floor=rs.getInt(2);
				repdata.Rep_Ploor=rs.getInt(3);
				repdata.Content=rs.getString(4);
				repdata.Tim_Post=rs.getString(5);
				repdata.Name_User=rs.getString(6);
				repdata.Pho_Rep=rs.getString(7);
				repdata.Integral_Rep=rs.getInt(8);
				Num_Page++;
				Replies.add(repdata);
			}
			rs.close();
		    dataconn.CloseCC();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
